import { RouteRecordRaw, Router, createRouter, createWebHistory } from "vue-router";

export const routes: RouteRecordRaw[] = [
  {
    path: '/',
    name: 'Default',
    redirect: { path: '/login' }
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('../views/login/index.vue'),
  },
  {
    path: '/home',
    name: 'Home',
    component: () => import('../views/home/index.vue'),
    meta: { title: '课程列表' },
    children: [
      {
        path: 'courses',
        name: 'Courses',
        component: () => import('../views/courses/CourseList.vue'),
        meta: { title: '全部课程' },
      },
      {
        path: 'favorites',
        name: 'Favorites',
        component: () => import('../views/courses/FavoriteList.vue'),
        meta: { title: '收藏列表' },
      }
    ]
  },
  {
    path: '/course',
    name: 'Course Manage',
    component: () => import('../views/home/index.vue'),
    meta: { title: '课程管理' },
    children: [
      {
        path: 'personal',
        name: 'Personal Courses',
        component: () => import('../views/manage/PersonalCourse.vue'),
        meta: { title: '我的课程' },
      },
      {
        path: 'create',
        name: 'Create Course',
        component: () => import('../views/manage/CreateCourse.vue'),
        meta: { title: '创建课程' },
      }
    ]
  },
  {
    path: '/information',
    name: 'Personal Information',
    component: () => import('../views/home/index.vue'),
    meta: { title: '个人信息管理' },
    children: [
      {
        path: 'voice',
        name: 'Voice Manage',
        component: () => import('../views/information/VoiceManage.vue'),
        meta: { title: '声音模型管理' },
      },
      {
        path: 'appearance',
        name: 'Appearance Manage',
        component: () => import('../views/information/AppearanceManage.vue'),
        meta: { title: '虚拟形象管理' },
      }
    ]
  }
];

const router: Router = createRouter({
  history: createWebHistory(),
  routes,
  scrollBehavior: () => ({ left: 0, top: 0 })
});

export default router;